hackerrank functions and fractals problem solution